<?php

/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2017/5/22
 * Time: 上午9:42
 */
abstract class dbObject
{
    const TABLE_NAME = 'undefined';

    public static function GetAll()
    {
        $c = get_called_class();
        return "SELECT * FROM `" . $c::TABLE_NAME . "`";
    }
}

class dbPerson extends dbObject
{
    const TABLE_NAME = 'persons';
}

class dbAdmin extends dbPerson
{
    const TABLE_NAME = 'admins';
}

echo dbPerson::GetAll() . "<br>";//output: "SELECT * FROM `persons`"
echo dbAdmin::GetAll() . "<br>";//output: "SELECT * FROM `admins`"
echo PHP_EOL;
$class = preg_replace('/_model$/ui','',"ui");
echo $class;
